require("../../assets/css/normalize.css");
require("../../assets/css/reset.css");
require("../../assets/fonts/iconfont.css");
require("../../assets/css/tabbar.less");
require("./mine.less");
// 引入模块
const dom = require("../../utils/dom.js");
const axios = require("../../utils/axios.js");

document.addEventListener("DOMContentLoaded", function () {
	// 底部导航选项卡切换
	dom.tabbar("mine");
	axios.get("/api/user/info").then(res => {
		let data = res.data.data;
		// console.log(data);
		dom.get("#signture").textContent = data.sign;
		dom.get("#username").textContent = data.nickName;
		dom.get("#avator").src = axios.defaults.baseURL + data.imgUrl;
	});
	// 点击我的运动数据按钮跳转到数据页面
	dom.get(".icon-xiangyou1").addEventListener("click", function () {
		location.href = "mine_sportsdate.html";
	});

	// 点击我的运动徽章按钮跳转到徽章页面
	dom.get(".btn2").addEventListener("click", function () {
		location.href = "mine_sportsbadge.html";
	});
	// 退出登录
	dom.get("#exitLogin").addEventListener("click", function () {
		location.href = "login.html";
	});
	// 渲染本周运动数据
	axios.get("/api/exercise").then(res => {
		console.log(res);
		dom.get("#time h1").textContent = res.data.data.sum7Duration;
		dom.get("#calorie h1").textContent = res.data.data.sum7Calorie;
	});
});
